package com.gxa.luckin.cart.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Configuration
public class Knife4jConfiguration {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .ignoredParameterTypes(HttpSession.class, HttpServletRequest.class,
                        HttpServletResponse.class)
                .groupName("1.0版本")
                .select()
                .apis(RequestHandlerSelectors.basePackage(
                        "com.gxa.luckin.cart"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("购物车接口swagger")
                .description("# cart测试APIs")
                .contact(fanyouzhao())
                .version("1.0")
                .build();
    }

    public Contact fanyouzhao(){
        return new Contact("范友钊", "", "944592024@qq.com");
    }
}
